program test_zgmres2
	use MySparseOperator
    implicit none
    integer :: ia(6), ja(13)
    complex(kind=8) :: a(13), expected_solution(5), rhs(5)
    complex(kind=8) :: x(5)
    integer :: maxiter, iter
    real(kind=8) :: maxrelres, relres

    integer :: ii

    ia = (/ 1,3,6,9,12,14 /)
    ja = (/ 1,      3,   &
        &   1,  2,      4,  &
        &       2,  3,      5,  &
        &           3,  4,  5,  &
        &               4,  5   /)
    a = (/  1.0,        -1.0,   &
        &   -1.0,   1.0,        -1.0,   &
        &       1.0,    -2.0,       1.0,    &
        &           -1.0,   2.0,    -1.0,   &
        &               -1.0,   -3.0 /)
    a = dcmplx( dreal(a), dreal(a) )
    expected_solution = dcmplx( (/ -1.0d0,1.0d0,0.0d0,1.0d0,-1.0d0 /),    &
            &   (/ 0.d0, 0.d0, 1.d0, 0.d0, 0.d0 /) )
    call mkl_zcsrgemv('n', 5, a, ia, ja, expected_solution, rhs)
    maxiter = 20
    maxrelres = 1.d-3
	call mso_zgmres_nonprecondition(maxiter, relres, a,ia,ja,rhs, x, iter, relres)


    write(unit=*, fmt=*) 'expected_solution and computed_solution'
    do ii = 1, 5, 1
        write(*,'(2("("D15.4","D15.5"i)"))') expected_solution(ii), x(ii)
    end do
    write(unit=*, fmt=*) 'iteration', iter
    write(unit=*, fmt=*) 'relative residual error', relres
    


    


end program test_zgmres2